Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Questions  >  What will be the output given program?#includ... Start Learning for Free
What will be the output given program?
#include<stdio.h>
void main()
{
    int i = -10;
    for(;i;printf("%d ", i++));
}
  • a)
    -10 to -1
  • b)
    -10 to infinite
  • c)
    -10 to 0
  • d)
    Complier error
Correct answer is option 'A'. Can you explain this answer?
Most Upvoted Answer
What will be the output given program?#include<stdio.h>void main...
Explanation:

Initialization:
- The variable i is initialized to -10.

For Loop:
- In the for loop condition, the expression i is evaluated.
- Since i is a non-zero value (-10), it is considered as true and the loop continues.

Loop Body:
- Inside the loop, the value of i is printed using the printf function.
- Then, i is incremented by 1 using the post-increment operator (i++).

Loop Iteration:
- The loop continues to run as long as the condition i is true.
- Since i is a non-zero value, the loop continues to print the value of i.

Output:
- The loop will continue to print the values of i starting from -10 and incrementing by 1 each time.
- The output will be: -10 -9 -8 -7 -6 -5 -4 -3 -2 -1
Therefore, the correct answer is option 'a' which states that the output will be -10 to -1.
Free Test
Community Answer
What will be the output given program?#include<stdio.h>void main...
for loop can be initialized outside of the loop. Since until -1 value of i remain a non-zero value and hence the condition is true up to -1. But when i is further increases its value becomes 0 and condition becomes false and loop stops there.
Note:In C any non-zero value(positive or negative) evaluates to true and only zero value is evaluates to false.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

What will be the output given program?#include<stdio.h>void main(){ int i = -10; for(;i;printf("%d ", i++));}a)-10 to -1b)-10 to infinitec)-10 to 0d)Complier errorCorrect answer is option 'A'. Can you explain this answer?
Question Description
What will be the output given program?#include<stdio.h>void main(){ int i = -10; for(;i;printf("%d ", i++));}a)-10 to -1b)-10 to infinitec)-10 to 0d)Complier errorCorrect answer is option 'A'. Can you explain this answer? for Computer Science Engineering (CSE) 2025 is part of Computer Science Engineering (CSE) preparation. The Question and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus. Information about What will be the output given program?#include<stdio.h>void main(){ int i = -10; for(;i;printf("%d ", i++));}a)-10 to -1b)-10 to infinitec)-10 to 0d)Complier errorCorrect answer is option 'A'. Can you explain this answer? covers all topics & solutions for Computer Science Engineering (CSE) 2025 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for What will be the output given program?#include<stdio.h>void main(){ int i = -10; for(;i;printf("%d ", i++));}a)-10 to -1b)-10 to infinitec)-10 to 0d)Complier errorCorrect answer is option 'A'. Can you explain this answer?.
Solutions for What will be the output given program?#include<stdio.h>void main(){ int i = -10; for(;i;printf("%d ", i++));}a)-10 to -1b)-10 to infinitec)-10 to 0d)Complier errorCorrect answer is option 'A'. Can you explain this answer? in English & in Hindi are available as part of our courses for Computer Science Engineering (CSE). Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free.
Here you can find the meaning of What will be the output given program?#include<stdio.h>void main(){ int i = -10; for(;i;printf("%d ", i++));}a)-10 to -1b)-10 to infinitec)-10 to 0d)Complier errorCorrect answer is option 'A'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of What will be the output given program?#include<stdio.h>void main(){ int i = -10; for(;i;printf("%d ", i++));}a)-10 to -1b)-10 to infinitec)-10 to 0d)Complier errorCorrect answer is option 'A'. Can you explain this answer?, a detailed solution for What will be the output given program?#include<stdio.h>void main(){ int i = -10; for(;i;printf("%d ", i++));}a)-10 to -1b)-10 to infinitec)-10 to 0d)Complier errorCorrect answer is option 'A'. Can you explain this answer? has been provided alongside types of What will be the output given program?#include<stdio.h>void main(){ int i = -10; for(;i;printf("%d ", i++));}a)-10 to -1b)-10 to infinitec)-10 to 0d)Complier errorCorrect answer is option 'A'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice What will be the output given program?#include<stdio.h>void main(){ int i = -10; for(;i;printf("%d ", i++));}a)-10 to -1b)-10 to infinitec)-10 to 0d)Complier errorCorrect answer is option 'A'. Can you explain this answer? tests, examples and also practice Computer Science Engineering (CSE) tests.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Explore Courses
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev